/*
 * bio.cpp
 *
 *  Created on: Aug 12, 2011
 *      Author: Pierre Lindenbaum PhD
 *              plindenbaum@yahoo.fr
 *              http://plindenbaum.blogspot.com
 *              
 */

#include "bio.h"

int normalize_base(int c)
    {
    switch(c)
    	{
    	case 'A':case 'T':case 'G': case 'C': return c;
    	case 'a': return 'A';
    	case 't': return 'T';
    	case 'g': return 'G';
    	case 'c': return 'C';
    	default:  return 'N';
    	}
    }

NucleotideSequence::NucleotideSequence(const CharSequence* owner):SubStringSequence(owner)
    {
    }

NucleotideSequence::~NucleotideSequence()
    {
    }

char NucleotideSequence::at(size_type idx) const
    {
    return normalize_base(_delegate->at(idx));
    }

ReverseComplementString::ReverseComplementString(const CharSequence* owner):NucleotideSequence(owner)
    {
    }

ReverseComplementString::~ReverseComplementString()
	{

	}

char ReverseComplementString::at(size_type idx) const
    {
    switch(_delegate->at((_delegate->size()-1)-idx))
	{
	case 'A': return 'T';
	case 'T': return 'A';
	case 'G': return 'C';
	case 'C': return 'G';
	case 'a': return 't';
	case 't': return 'a';
	case 'g': return 'c';
	case 'c': return 'g';
	default:  return 'N';
	}
    }

